import type { ActionButton } from '@/components/table/src/types/action-button';

export function computeOperationsColumnWidth(operations: ActionButton[], maxVisibleOperations: number) {
  if (operations.length > maxVisibleOperations) {
    return operations.slice(0, maxVisibleOperations - 1)
      .reduce((total, operation) => {
        return total + 32 + operation.name.length * 12;
      }, 0)
      + (operations.length - 1) * 6 + 28 + 120;
  }

  return operations.reduce((total, operation) => {
    return total + 32 + operation.name.length * 12;
  }, 0)
  + (operations.length - 1) * 6 + 28;
}
